//
//  SDMyReportData.m
//
//  Created by   on 2018/11/16
//  Copyright (c) 2018 __MyCompanyName__. All rights reserved.
//

#import "SDMyReportData.h"


NSString *const kSDMyReportDataCreateTime = @"createTime";
NSString *const kSDMyReportDataScore = @"score";
NSString *const kSDMyReportDataNickName = @"nickName";
NSString *const kSDMyReportDataHeadImg = @"headImg";
NSString *const kSDMyReportDataId = @"id";


@interface SDMyReportData ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation SDMyReportData

@synthesize createTime = _createTime;
@synthesize score = _score;
@synthesize nickName = _nickName;
@synthesize headImg = _headImg;
@synthesize id = _id;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict {
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict {
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if (self && [dict isKindOfClass:[NSDictionary class]]) {
            self.createTime = [self objectOrNilForKey:kSDMyReportDataCreateTime fromDictionary:dict];
            self.score = [self objectOrNilForKey:kSDMyReportDataScore fromDictionary:dict];
            self.nickName = [self objectOrNilForKey:kSDMyReportDataNickName fromDictionary:dict];
            self.headImg = [self objectOrNilForKey:kSDMyReportDataHeadImg fromDictionary:dict];
            self.id = [self objectOrNilForKey:kSDMyReportDataId fromDictionary:dict];

    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation {
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.createTime forKey:kSDMyReportDataCreateTime];
    [mutableDict setValue:self.score forKey:kSDMyReportDataScore];
    [mutableDict setValue:self.nickName forKey:kSDMyReportDataNickName];
    [mutableDict setValue:self.headImg forKey:kSDMyReportDataHeadImg];
    [mutableDict setValue:self.id forKey:kSDMyReportDataId];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description  {
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict {
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];

    self.createTime = [aDecoder decodeObjectForKey:kSDMyReportDataCreateTime];
    self.score = [aDecoder decodeObjectForKey:kSDMyReportDataScore];
    self.nickName = [aDecoder decodeObjectForKey:kSDMyReportDataNickName];
    self.headImg = [aDecoder decodeObjectForKey:kSDMyReportDataHeadImg];
    self.id = [aDecoder decodeObjectForKey:kSDMyReportDataId];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_createTime forKey:kSDMyReportDataCreateTime];
    [aCoder encodeObject:_score forKey:kSDMyReportDataScore];
    [aCoder encodeObject:_nickName forKey:kSDMyReportDataNickName];
    [aCoder encodeObject:_headImg forKey:kSDMyReportDataHeadImg];
    [aCoder encodeObject:_id forKey:kSDMyReportDataId];
}

- (id)copyWithZone:(NSZone *)zone {
    SDMyReportData *copy = [[SDMyReportData alloc] init];
    
    
    
    if (copy) {

        copy.createTime = [self.createTime copyWithZone:zone];
        copy.score = [self.score copyWithZone:zone];
        copy.nickName = [self.nickName copyWithZone:zone];
        copy.headImg = [self.headImg copyWithZone:zone];
        copy.id = [self.id copyWithZone:zone];
    }
    
    return copy;
}


@end
